<#assign contextPath=springMacroRequestContext.getContextPath() />
<#import "/public/frame/main.html" as frame />
<@frame.head ""> </@frame.head>

<script type="text/javascript">
	var path = "${contextPath}";
</script>
<script type="text/javascript"
	src="${contextPath}/resources/js/tool/ckeditor/ckeditor.js"></script>
<div class="page-container">

	<form action="${contextPath}/finetTalk/speak_add" method="post"
		class="form form-horizontal" id="jvForm" enctype="multipart/form-data">

		<div>
        <tr>
            <td width="20%">
                <span>*</span>
                上传封面图片(90x150尺寸):</td>
                <td width="80%">
                 注:该尺寸图片必须为90x150。
                </td>
        </tr>
                <tr>
                 <td width="20%"></td>
                    <td width="80%">
                        <img width="100" height="100" id="allUrl" />
                        <!-- 在选择图片的时候添加事件，触发Ajax异步上传 -->
                        <input name='pic' type="file" id="imag"
					onchange="imgee(this)" />
                     </td>
                </tr>
        </div>


		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				标题：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" placeholder="" id="title"
					name="title">
			</div>
		</div>
		<div class="mt-20 skin-minimal">
				<label class="form-label col-xs-4 col-sm-2">
					<span class="c-red">*</span>
					导航分类：</label>
				<div class="radio-box">
					<input type="radio" id="isPy-1" name="navigation" value="1" checked>
					<label for="radio-2">推荐 </label>
					<!-- <input type="radio"  id="isPay1" name="isPay" value="1" checked /> 免费 -->
				</div>
				<div class="radio-box">
					<input type=radio id="isPay-2" name="navigation"
					onclick="this.form.txt.style.display=''" value="5">
					<label for="radio-1">速写</label>
				</div>
				<div class="radio-box">
					<input type=radio id="isPay-2" name="navigation"
					onclick="this.form.txt.style.display=''" value="3">
					<label for="radio-1">素描</label>
				</div>
				<div class="radio-box">
					<input type=radio id="isPay-2" name="navigation"
					onclick="this.form.txt.style.display=''" value="4">
					<label for="radio-1">色彩</label>
				</div>
				</div>
		<div class="mt-20 skin-minimal">
				<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				是否置顶：</label>
				<div class="radio-box">
					<input onclick="show(1)" type="radio" id="isPy-1" name="topping"
					value="1" checked>
					<label for="radio-2" >是</label>
				</div>
				
			
				<div class="radio-box">
					<input onclick="show(2)" type=radio id="isPay-2" name="topping"
					value="0" >
					<label for="radio-1" >否</label>
				</div>
				</div>
			<div id="paixu" class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				排序：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" placeholder=""
					id="serialNumber" name="serialNumber" >
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				简介：</label>
			<div class="formControls col-xs-6 col-sm-6">
				
				<textarea cols="80" id="content" name="content"></textarea> 
             <script type="text/javascript">
														window.onload = function() {
															CKEDITOR
																	.replace(
																			'content',
																			{
																				filebrowserUploadUrl : path
																						+ '/ckeditor/uploader?Type=File&prodId=1111&uploadModel=product',
																				filebrowserImageUploadUrl : path
																						+ '/ckeditor/uploader?Type=Image&prodId=${1111}&uploadModel=product',
																				filebrowserFlashUploadUrl : path
																						+ '/ckeditor/uploader?Type=Flash&prodId=${1111}&uploadModel=product'
																			});
														}
													</script>
			</div>
		</div>
		<div class="row cl">
			<div class="col-9 col-offset-2">
				<input class="btn btn-primary radius" onclick="submitFinetTalk()"
					value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
			</div>
	
	</form>
</div>
<@frame.end "default">
</@frame.end>


</html>
<script type="text/javascript">
	var path = "${contextPath}";
	
	
	function getObjectURL(file) {
		var url = null;
		if (window.createObjectURL != undefined) {
			url = window.createObjectURL(file)
		} else if (window.URL != undefined) {
			url = window.URL.createObjectURL(file)
		} else if (window.webkitURL != undefined) {
			url = window.webkitURL.createObjectURL(file)
		}
		return url
	};

	function imgee(obj) {

		// 上传设置
		var imgObj = getObjectURL(obj.files[0]);//获取图片
		$("#allUrl").attr("src", imgObj);

	}
	function submitFinetTalk() {
		var patternNum=/^[0-9]*$/;
		var title=$("#title").val();
		var imag=$("#imag").val();
		var serialNumber=$("#serialNumber").val();
		if(imag=="" || imag.length==0){
			layer.alert("请选择要上传的图片！");
			return false;
		}
		if(title=="" || title.length==0){
			layer.alert("标题不能为空！");
			return false;
		}
		if (!patternNum.test(serialNumber)) {
			layer.alert("序号只能填写数字！");
			return false;
		}
		var content = CKEDITOR.instances.content.getData();
		$("#content").val(content);
		$("#jvForm").ajaxSubmit({
			dataType : 'text',
			success : function(message) {
				if (message == "200") {
					layer.msg('上传成功!', {
						icon : 1,
						time : 1000
					}, function() {
						parent.window.location.reload();
					});
				} else if (message == "505") {
					/* layer.alert("只有老师机构管理员才能操作"); */
				} else if (message == "500") {
					alert(message.message);

				} else {
					alert(message.message);
				}
			},
			error : function() {
				layer.msg('操作失败!', {
					icon : 5,
					time : 1000
				});
			},
			complete : function(XMLHttpRequest, textStatus) {
			}
		});
	}
	 function show(type) {
			if(type==1){
				$("#paixu").show();
				
			}else{
				$("#paixu").hide();
				
			}
	 }
</script>
